home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 0022-3.564 / dmg-3442 / st_applc / cookies / prog1.txt next >
Text File  |  1992-04-03  |  4KB  |  124 lines

  1. *       Show contents of Cookie Jar
  2. *       (c) 1991 Mathew Lodge
  3.  
  4. _p_cookies equ  $5A0            Cookie jar pointer
  5.  
  6. dos     equ     1
  7. xbios   equ     14
  8.  
  9. Pterm0  equ     $00
  10. Cconws  equ     $09
  11.  
  12. Supexec equ     38
  13.  
  14.  
  15. start:
  16.         move.l  #stack,sp       Set up our stack
  17.         pea     disp_jar
  18.         move.w  #Supexec,-(sp)
  19.         trap    #xbios          Execute routine in super mode
  20.         addq.l  #6,sp
  21.  
  22.         move.w  #Pterm0,-(sp)   Terminate
  23.         trap    #1
  24.  
  25. disp_jar:
  26.         move.l  _p_cookies,d0
  27.         beq     no_jar          If pointer zero, no jar installed
  28.         move.l  d0,a0
  29. loop:
  30.         move.l  (a0)+,d0        Get cookie ID
  31.         move.l  (a0)+,d1        Get cookie value
  32.         tst.l   d0              End of jar?
  33.         beq     jar_end
  34.         bsr     show_cookie     Otherwise show cookie
  35.         bsr     print_crlf      Goto next line
  36.         bra     loop
  37.  
  38. no_jar:
  39.         lea     no_jarm,a1      No jar message
  40.         bsr     print_stg
  41.         rts                     Done
  42.  
  43. jar_end:
  44.         lea     end_msg,a1      Print end of jar message
  45.         bsr     print_stg
  46.         lea     scratch,a1
  47.         bsr     print_hex       Print no of slots in jar
  48.         bsr     print_crlf      Add CRLF
  49.         rts                     Done
  50.  
  51. show_cookie:
  52.         lea     scratch,a1      Scratch buffer
  53.         move.l  d0,(a1)+        Store ID
  54.         move.l  #" = $",(a1)+
  55.         clr.b   (a1)            Zero terminate
  56.         lea     scratch,a1      Print it
  57.         bsr     print_stg
  58.         lea     scratch,a1
  59. *                               Fall through to print_hex
  60.  
  61. print_hex:
  62.         move.l  a1,-(sp)        Save buffer address
  63.         bsr     print_hex_l     Store in buffer
  64.         clr.b   (a1)            Zero terminate
  65.         move.l  (sp)+,a1        Fall through to print_stg
  66.  
  67. print_stg:
  68.         movem.l d0-d1/a0-a1,-(sp) Save registers
  69.         move.l  a1,-(sp)
  70.         move.w  #Cconws,-(sp)   Print to screen
  71.         trap    #dos
  72.         addq.l  #6,sp
  73.         movem.l (sp)+,d0-d1/a0-a1 Retrieve regs
  74.         rts
  75.  
  76. print_crlf:
  77.         lea     crlf,a1         Print carriage return
  78.         bra     print_stg       and line feed
  79.  
  80. print_hex_l:
  81.         swap    d1              Print high word first
  82.         bsr     print_hex_w
  83.         swap    d1
  84.         bsr     print_hex_w     Then low word
  85.         rts
  86.  
  87. print_hex_w:
  88.         move.l  d1,-(sp)        Save D1
  89.         lsr.w   #8,d1           Shift low byte into d1
  90.         bsr     print_hex_b     Print it
  91.         move.l  (sp),d1         Get D1 back (but don't unstack)
  92.         bsr     print_hex_b     Print it
  93.         move.l  (sp)+,d1        Get D1 back
  94.         rts
  95.  
  96. print_hex_b:
  97.         move.l  d1,-(sp)        Save D1
  98.         lsr.w   #4,d1           Shift high nybble into D1
  99.         bsr     lookup          Decode it
  100.         move.l  (sp)+,d1        Get D1 back
  101.         bsr     lookup          Decode low nybble
  102.         rts
  103.  
  104. lookup:
  105.         and.l   #$F,d1          mask off rest
  106.         lea     hextable,a2     Look up table
  107.         move.b  0(a2,d1.w),d2   Get ASCII equivalent
  108.         move.b  d2,(a1)+        Save in scratch buffer
  109.         rts
  110.  
  111. hextable:
  112.         dc.b    '0123456789ABCDEF'
  113.  
  114. no_jarm dc.b    'No Cookie Jar installed',13,10,0
  115. end_msg dc.b    'Total no of cookie slots :',0
  116. crlf    dc.b    13,10,0
  117. scratch:
  118.         ds.l    4
  119.         
  120.         ds.l    99
  121. stack   ds.l    1
  122.  
  123.         END
  124.